#include "CharacterFightInfo.h"
#include "Character\PlayerCharacter.h"
#include "qpainter.h"

CharacterFightInfo::CharacterFightInfo(PlayerCharacter &iCharacter) : mCharacter(iCharacter)
{
	setFixedWidth(300);
}

void CharacterFightInfo::paintEvent(QPaintEvent *event)
{
	QPainter qpainter(this);
	QFont header = this->font();
	header.setPointSize(10);
	int x = 10;
	int y = 20;
	int sp = 20;
	int fh = header.pointSize() * 2;

	// Player area
	qpainter.setFont(header);
	qpainter.drawText(x,y, mCharacter.getName().c_str());
	y += header.pointSize() + sp;
	qpainter.drawImage(x, y, *(mCharacter.getPicture()));

	x += mCharacter.getPicture()->width() + sp;
	
	qpainter.drawText(x, y, "Characteristics: ");

	if (mCharacter.isToad())
	{
		y += fh * 2;
		qpainter.drawText(x, y, QString("Strength value: N/A"));
		y += fh;
		qpainter.drawText(x, y, QString("Strength counter: N/A"));
		y += fh;
		qpainter.drawText(x, y, QString("From followers: N/A"));
	}
	else
	{
		y += fh * 2;
		qpainter.drawText(x, y, QString("Strength value: ").append(QString::number(mCharacter.getStrengthValue())));
		y += fh;
		qpainter.drawText(x, y, QString("Strength counter: ").append( QString::number(mCharacter.getStrengthCounter())));
		y += fh;
		int wFromFollowers = mCharacter.getTotalCharacterStrength()-mCharacter.getStrengthValue() - mCharacter.getStrengthCounter();
		qpainter.drawText(x, y, QString("From followers: ").append( QString::number(wFromFollowers)));
	}

	y += fh;
	qpainter.drawText(x, y, QString("------------------------"));
	y += fh;
	qpainter.drawText(x, y, QString("Total strength: ").append( QString::number(mCharacter.getTotalCharacterStrength())));
}